<?php

namespace teamug;

/* 
 * For use by a RequestHandler when it is to return HTML
 *  
 */

class HtmlResponse {
  
  private $data;
  private $javascripts = array();
  private $stylesheets = array();
  private $templates;
  
  public function __construct() {
    $this->templates = new Templates;
    $this->data = new stdClass;
  }
  
  public function addJavascript($filePath) {
    $this->javascripts[] = "<script src=\"$filePath\"></script>";
  }
  
  public function addStylesheet($filePath, $media=screen) {
    $this->stylesheets[] = "<link rel=\"stylesheet\" type=\"text/css\" href=\"$filePath\" media=\"$media\" />";
  }

  public function getJavascripts($glue="\n") {
    return implode($glue, $this->javascripts);
  }
  
  public function getStylesheets($glue="\n") {
    return implode($glue, $this->stylesheets);
  }

  public function __get($name) {
  
    if (\array_key_exists($name, $this->userData)) {
      return $this->userData[$name];
    } else {
      trigger_error("Data item '$name' not found in ".get_class($this), E_USER_WARNING);
      return null;
    }
  }
  
}


